package com.originskyseed.platform.count.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.originskyseed.platform.core.aspect.annotation.RequiredParams;
import com.originskyseed.platform.core.base.BaseController;
import com.originskyseed.platform.core.base.BaseLocaleResource;
import com.originskyseed.platform.core.base.BasePage;
import com.originskyseed.platform.core.base.BaseResponseBody;
import com.originskyseed.platform.core.common.code.CommonResponseCode;
import com.originskyseed.platform.count.i18n.CountResponseMsg;
import com.originskyseed.platform.count.model.TeamAchievement;
import com.originskyseed.platform.count.service.ITeamAchievementService;
import com.originskyseed.platform.count.vo.request.TeamAchievementRequestVO;

/**
 * 小组业绩信息表Controller类（OSI_TEAM_ACHIEVEMENT）
 * 
 * @author Tangwanghui
 */
@Controller
@RequestMapping("/teamAchievement")
@BaseLocaleResource(localeFileName = "i18n_count")
public class TeamAchievementController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(TeamAchievementController.class);

	@DubboReference
	private ITeamAchievementService teamAchievementService;

	/**
	 * 分页查询
	 * 
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/teamAchievementList.json", method = RequestMethod.POST)
	@RequiredParams(names = { "pageNo", "pageSize" })
	public BaseResponseBody<BasePage<TeamAchievement>> teamAchievementList(HttpServletRequest request) {
		BaseResponseBody<BasePage<TeamAchievement>> result = null;
		try {
			// 请求对象
			TeamAchievementRequestVO requestVO = this.getParameterBean(TeamAchievementRequestVO.class);

			// 分页查询
			BasePage<TeamAchievement> page = new BasePage<TeamAchievement>(requestVO.getPageNo(), requestVO.getPageSize());
			page = this.teamAchievementService.selectListByPage(requestVO.toMap(), page);
			result = new BaseResponseBody<BasePage<TeamAchievement>>(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), CountResponseMsg.DATA_SELECT_SUCCESS.getMsg()), page);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody<BasePage<TeamAchievement>>(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), CountResponseMsg.DATA_SELECT_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

}